//
//  Fifth.m
//  A段项目
//
//  Created by dllo on 16/1/22.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "Fifth.h"
#import "FifthViewForFirstCell.h"
#import "FifthViewFooterView.h"
#import "ChooseLocalPhotoLibView.h"
#import "EditInfoController.h"
#import <UIImageView+WebCache.h>
#import "SettingViewController.h"


@interface Fifth () <UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) NSMutableArray *array;


@end

@implementation Fifth

- (void) dealloc {
    
     [[NSNotificationCenter defaultCenter] removeObserver:self];
    
    [_choose release];
    [_array release];
    [_tableView release];
    [super dealloc];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
   
    
    [self creatTableView];
    
    [self reciveImage];
    
    self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"set"] style:1 target:self action:@selector(settingPrefre)];
    
    self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
    
}

#pragma mark -- 设置界面

- (void)settingPrefre {
    
    SettingViewController *set = [[SettingViewController alloc] init];
    
    [self.navigationController pushViewController:set animated:YES];
    
    [set release];
    
    
}


- (void)creatTableView {
    
    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    
    [self.view addSubview:self.tableView];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = 0;
    
    [self.tableView registerClass:[FifthViewForFirstCell class] forCellReuseIdentifier:@"pool1"];
    
    [self.tableView registerClass:[FifthViewFooterView class] forHeaderFooterViewReuseIdentifier:@"pool2"];
    
}

- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
   
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
   
    FifthViewForFirstCell *cell = [tableView dequeueReusableCellWithIdentifier:@"pool1"];
    
    
    return cell;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    
    FifthViewFooterView *footer = [self.tableView dequeueReusableHeaderFooterViewWithIdentifier:@"pool2"];

    return footer;
    
}

- (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    
    
    
    return 50;
}

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    return 230;
}


#pragma mark --子控件的
/**接收图片*/
/*推出界面 "本地"*/
- (void)reciveImage {
    
    self.choose = [[ChooseLocalPhotoLibView alloc] init];
    
    self.choose.arrLocalPic = [NSMutableArray array];
    
    // 接收系统图片.
    [[NSNotificationCenter defaultCenter] addObserverForName:@"getAllPic" object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
        
    
        self.choose.arrLocalPic = [note.userInfo objectForKey:@"data"];
        
        self.choose.arrForAsset = [note.userInfo objectForKey:@"arrayForAsset"];
        
        [self.navigationController pushViewController:self.choose animated:YES];
        
        
    }];
    
    
    [_choose release];
    
}


- (void)viewWillAppear:(BOOL)animated {
    
    self.navigationItem.title = @"我";
    
    self.tabBarController.tabBar.hidden = NO;
    
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshCollectCount" object:nil];
    
}

- (void)viewDidAppear:(BOOL)animated {
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"viewAppeared" object:nil];  //当从本地页面退回到本页面是 給 choosePictureCell ,和chooseLoacl 界面发通知 用来将 button 去色和 选中状态清零

    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
